﻿/*======================================
作者：洞庭夕照
创建：2017.10.17
网站：www.ninesky.cn
      mzwhj.cnblogs.com
支持：bbs.ninesky.cn
代码：git.oschina.net/ninesky/Ninesky
版本：v1.0.0.0
======================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Ninesky.IService;
using Ninesky.Models;

namespace Ninesky.MVC.Areas.Member.Controllers
{
    /// <summary>
    /// 栏目
    /// </summary>
    [Area("Member")]
    public class CategoryController : Controller
    {
        /// <summary>
        /// 栏目接口
        /// </summary>
        private ICategoryService _categoryService { get; set; }

        public CategoryController(ICategoryService categoryService)
        {
            _categoryService = categoryService;
        }


        #region Json
        /// <summary>
        /// 查询栏目【根据模块类型】
        /// </summary>
        /// <param name="type">模块类型</param>
        /// <param name="inclParent">包含父栏目</param>
        /// <returns></returns>
        public async Task<IActionResult> GeneralByModuleType(int type = 0, bool inclParent = true)
        {
            return new JsonResult((await _categoryService.FindListAsync(CategoryType.General, (ModuleType)type, inclParent)).ToList());
        }
        #endregion
    }
}